package com.aizhixin.quick.controller;


import com.aizhixin.quick.dto.ExamTypeSaveDTO;
import com.aizhixin.quick.dto.UpdateExamTypeDTO;
import com.aizhixin.quick.service.ExamTypeService;
import com.aizhixin.quick.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-09
 */
@RestController
@Api(tags = "试题分类基础操作")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/examType")
public class ExamTypeController {

    @Autowired
    ExamTypeService examTypeService;

/*
查询所有试题类型
 */
    @GetMapping("/listAllExamType")
    public Result getAllExamType(){
         examTypeService.list();
        return Result.ok();
    }

/*
添加试题分类
 */
    @PostMapping("/saveExamType")
    public Result sava(@ApiParam(value = "dto") @Validated @RequestBody ExamTypeSaveDTO deptAddDTO ){
        examTypeService.save();
        return Result.ok();
 }

 /*
 更改试题分类信息
  */
    @PutMapping("/updateByid")
    public Result updateByid(){
     examTypeService.updateById();
     return Result.ok();
 }


 /**
 * 根据分类名称查找
 * @parm examTypeName
 */
    @GetMapping("/getByName")
    public Result getByName(){
     examTypeService.listByMap();
     return Result.ok();
}

/*
  根据分类等记查找
  传入 examTypeName
 */
    @GetMapping("/getByLevel")
    public Result getByLevel(){
    examTypeService.listByMap();
    return Result.ok();
}

/*
根据id 删除试题分类
 */
    @GetMapping("/deleteByid")
    public Result deleteByid(){
    examTypeService.removeById();
    return Result.ok();
}



}

